Tutaj znajduje sie ukryty chunk, w ktorym wczytujemy pakiety (np. library(tidyverse)) oraz surowe dane
A tu jest przyklad blockquote’a
Surowe dane wygladaja nastepujaco:
as_tibble(data.raw.df)
## # A tibble: 1,890 x 6
## Date Brand Film.Code Ratecard.Durati~ Metric Value
## <chr> <chr> <chr> <int> <chr> <dbl>
## 1 2017-05-15 Blend a med Blend a med 3d white l~ 30 Cost 7.07e5
## 2 2017-05-15 Blend a med Blend a med 3d white l~ 30 TRP 1.38e1
## 3 2017-05-16 Blend a med Blend a med 3d white l~ 30 Cost 1.35e6
## 4 2017-05-16 Blend a med Blend a med 3d white l~ 30 TRP 2.50e1
## 5 2017-05-17 Blend a med Blend a med 3d white l~ 30 Cost 9.32e5
## 6 2017-05-17 Blend a med Blend a med 3d white l~ 30 TRP 1.88e1
## 7 2017-05-18 Blend a med Blend a med 3d white l~ 30 Cost 1.13e6
## 8 2017-05-18 Blend a med Blend a med 3d white l~ 30 TRP 1.19e1
## 9 2017-05-19 Blend a med Blend a med 3d white l~ 30 Cost 1.08e6
## 10 2017-05-19 Blend a med Blend a med 3d white l~ 30 TRP 2.28e1
## # ... with 1,880 more rows
Dane o aktywnosci i kosztach TV zostały wczytane i przerobione na format długi:
data.prep.df <- data.raw.df %>%
mutate(Date = as.Date(Date),
Date = lubridate::floor_date(Date, unit = 'months')) %>%
group_by(Date, Metric) %>%
summarise(Value = sum(Value)) %>%
ungroup() %>%
pivot_wider(names_from = 'Metric',
values_from = 'Value',
values_fill = 0)
Poniższy wykres przedstawia zsumowaną wartość wydatków TV brandów kosmetycznych w zadanym okresie czasu.
ggplot(data.prep.df, aes(x = Date)) +
geom_line(aes(y = Cost)) +
theme_minimal()
Rozklad normalny jest najczesciej wykorzystywanym rozkladem w statystyce
y = (1 / (sigma * sqrt(2*pi)) * exp(-0.5*((x-mu)/sigma)^2))
Zapis bardziej elegancki:
Wzor_z_internetu
Raporty knitowane do formatu HTML mogą być interaktywne przy wykorzystaniu takich pakietów jak:
data.prep.brands.df <- data.raw.df %>%
mutate(Date = as.Date(Date),
Date = lubridate::floor_date(Date, unit = 'months')) %>%
group_by(Date, Brand, Metric) %>%
summarise(Value = sum(Value)) %>%
ungroup() %>%
pivot_wider(names_from = 'Metric',
values_from = 'Value',
values_fill = 0)
plot_gg <- ggplot(data.prep.brands.df, aes(x = Date)) +
geom_line(aes(y = TRP, col = Brand)) +
theme_minimal()
plotly::ggplotly(plot_gg)